package com.flaremars.picker.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.flaremars.picker.R;
import com.flaremars.picker.adapters.LeafCardAdapter;
import com.flaremars.picker.entities.LeafCard;
import com.flaremars.picker.entities.LeafCardService;
import com.flaremars.picker.utils.StringUtils;

/**
 * @author FlareMars on 2016/3/12.
 * 图鉴页面
 */
public class CardsFragment extends Fragment implements LeafCardAdapter.OnCardItemClickListener {

    public CardsFragment() {

    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_single_listview,container,false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview_content);
        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(new LeafCardAdapter(getContext(), LeafCardService.INSTANCE.getAll(),this));
    }

    @Override
    public void onCardItemClickListener(LeafCard item) {
        if (StringUtils.INSTANCE.isEmpty(item.getLeafCardId())) {
            //处理未收集图鉴的点击事件
        } else {
            //处理已收集图鉴的点击事件
        }
    }
}
